﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using OConf.Entity;

namespace OConf.Service
{
    public class MyDBContext: DbContext
    {
        private IConfiguration _configuration { get; }
        public MyDBContext(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //注入mySql链接字符串
            optionsBuilder.UseMySql(_configuration.GetConnectionString("MySql"), ServerVersion.Parse(_configuration.GetConnectionString("DBVersion")))
                .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
        }

        public DbSet<ProjectInfoEntity> ProjectInfo { get; set; }
        public DbSet<ConfigInfoEntity> ConfigInfo { get; set; }
        public DbSet<CNameSpaceEntity> CNameSpace { get; set; }
        public DbSet<AdminsEntity> Admin { get; set; }
        public DbSet<LoginLogEntity> LoginLog { get; set; }
        public DbSet<VersionsEntity> Versions { get; set; }
        public DbSet<ConfigInfoHistoryEntity> ConfigInfoHistory { get; set; }
    }
}
